package com.demoLearn;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;

/**
 * @description:
 * @author: cyy
 **/
public class java_date {
    public static void main(String[] args) {
        //System.out.println("shitutuya:"+getPreYearMonth());

        System.out.println("shitutuya:"+getPreTenTime());
        /*DateTimeFormatter dateTimeFormatter =   DateTimeFormatter.ofPattern("dd-MM-yyyy hh:mm:ss");  //12小时
         DateTimeFormatter dateTimeFormatter =   DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");   //24小时
        String localDateTime=dateTimeFormatter.format(LocalDateTime.now());
        System.out.println("shitutuya:"+ dateTimeFormatter.format(LocalDateTime.now()));*/
    }

    /**
     *获取当前天的后一天
     */
    public static String getPreYearMonth(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH,+1);
        return sdf.format(cal.getTime());
    }

    /**
     *获取当前天的前十分钟
     */
    public static String getPreTenTime(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MINUTE,-10);
        return sdf.format(cal.getTime());
    }
}
